﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using QuanLyHocPhi.BLL;
using QuanLyHocPhi.Model;

namespace QuanLyHocPhi.GUI.DuLieu
{
    public partial class FormDieuChinhMucThu : Form
    {
        private MucThu m_MucThu;

        public FormDieuChinhMucThu(MucThu mucThu, string tenLop, string hocKy)
        {
            InitializeComponent();

            m_MucThu = mucThu;
            lblLop.Text = tenLop;
            lblHocKy.Text = hocKy;

            DisplayObject();
        }

        private void DisplayObject()
        {
            nudHocPhi.Value = m_MucThu.HocPhi;
            nudLePhi.Value = m_MucThu.LePhi;
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            var hocPhi = Convert.ToInt32(nudHocPhi.Value);
            var lePhi = Convert.ToInt32(nudLePhi.Value);
            try
            {
                BizPhiMacDinh.UpdatePhiMacDinh(m_MucThu, hocPhi, lePhi);
                m_MucThu.HocPhi = hocPhi;
                m_MucThu.LePhi = lePhi;
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                this.Close();
            }
            catch (Exception exc)
            {
                DialogUtils.ShowError("Không điều chỉnh mức thu được.\nChi tiết lỗi: " + exc.Message);
            }
        }
    }
}
